﻿Public Class ctlAuditTrail

    Public Event Reload()

    Private _DataTable As DataTable

    Private Sub ctlAuditTrail_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        cboStartDate.Value = Date.Today

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        RaiseEvent Reload()
    End Sub

    Public WriteOnly Property Table As DataTable
        Set(ByVal value As DataTable)
            _DataTable = value
        End Set
    End Property

    Private Function Users() As IList
        'distinct non funziona ancora.
        Try
            Dim ret As IList = (From x In _DataTable.AsEnumerable
                                Select New With {.Username = x("username"), .userid = x("userid")}).Distinct.ToList

            Return ret

        Catch
            Return Nothing

        End Try

    End Function

    Private Sub cboUsername_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboUsername.DropDown
        With cboUsername
            .DataSource = Users()
            .DisplayMember = "Username"
            .ValueMember = "UserId"
        End With

    End Sub
End Class
